import unittest

class URIResolverTestCase(unittest.TestCase):
    def setUp(self):
        from pennypress.apps.ReST.models import RecurringSidebar
        # Create a RecurringSidebar object
        self.sidebar = RecurringSidebar(title="Title",
                                        subtitle="SubTitle",
                                        slug="test",
                                        text="Text")
        self.sidebar.save()

    def testURIResolver(self):
        from pennypress.apps.ReST import uri_resolver

        # Call the lookup
        obj = uri_resolver.resolve("/recurring-sidebar/test/")
        
        # Assert that the resolved object is the object we created
        self.assertEqual(obj.id, self.sidebar.id)

class MarkupTestCase(unittest.TestCase):
    def testMarkup(self):
        from pennypress.apps.ReST.models import RecurringSidebar
        from pennypress.apps.ReST.markup import markup
        fixture = u"""<div class="document" id="heading-1">
<h1 class="title">Heading 1</h1>
<p>This is the first paragraph</p>
<p>This is the second paragraph</p>
<div class="section">
<h2><a id="subheading" name="subheading">Subheading</a></h2>
<p>This is the third paragraph</p>
</div>
</div>
"""
        story_rst = """
Heading 1
=========

This is the first paragraph

This is the second paragraph

Subheading
----------

This is the third paragraph
"""
        result = markup(story_rst)
        # Assert that the fixture and the result are equal
        self.assertEquals(result, fixture)
